package net.entelijan.cobean.bind;

public abstract class BindingStrategyFactory {

	private BindingStrategyFactory() {
		super();
	}

	public static IPropertyBindingStrategy createBindingStrategy() {
		return createBindingStrategy(getDefaultBindingStrategyName());
	}

	private static String getDefaultBindingStrategyName() {
		return "net.entelijan.cobean.bind.impl.SpringPropertyBindingStrategy";
	}

	private static IPropertyBindingStrategy createBindingStrategy(
			String className) {
		try {
			return (IPropertyBindingStrategy) Class.forName(className)
					.newInstance();
		} catch (Exception e) {
			throw new IllegalStateException(
					"Could not create a binder for class '" + className + "'. "
							+ e.getMessage(), e);
		}
	}

}
